package com.bitdf.txing.group.feign.impl.cart;

import com.bitdf.txing.cart.feign.CartProductFeignService;
import com.bitdf.txing.common.utils.R;
import com.bitdf.txing.product.dao.SkuInfoDao;
import com.bitdf.txing.product.entity.SkuInfoEntity;
import com.bitdf.txing.product.service.SkuSaleAttrValueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Lizhiwei
 * @date 2023/9/5 23:25:11
 * 注释：
 */
@Service
@ConditionalOnProperty(value = "tx.deploy.mode", havingValue = "standalone")
public class CartProductFeignServiceImpl implements CartProductFeignService {
    @Autowired
    SkuInfoDao skuInfoDao;
    @Autowired
    SkuSaleAttrValueService skuSaleAttrValueService;
    @Override
    public R getSkuInfo(Long skuId) {
        SkuInfoEntity skuInfo = skuInfoDao.selectById(skuId);
        return R.ok().put("data", skuInfo);
    }

    @Override
    public List<String> getSkuSaleAttrValues(Long skuId) {
        return skuSaleAttrValueService.getSkuSaleAttrValuesAsStringList(skuId);
    }

    @Override
    public R getPrice(Long skuId) {
        SkuInfoEntity skuInfo = skuInfoDao.selectById(skuId);
        return R.ok().setData(skuInfo.getPrice().toString());
    }
}
